Getting Started#

topicwizard is a pretty and opinionated Python library for topic model visualization built on Dash and Plotly. This website contains the user guide to topicwizard as well as the API reference.

Installation#

topicwizard can be simply installed by installing the PyPI package.

pip install topic-wizard

Usage#

Open In Colab

Train a scikit-learn compatible topic pipeline.

Note

If you intend to investigate non-scikit-learn models, please have a look at Compatibility

from sklearn.decomposition import NMF
from sklearn.feature_extraction.text import CountVectorizer
from topicwizard.pipeline import make_topic_pipeline

bow_vectorizer = CountVectorizer()
nmf = NMF(n_components=10)
topic_pipeline = make_topic_pipeline(bow_vectorizer, nmf)
topic_pipeline.fit(texts)

The easiest and most sensible way to visualize is with the topicwizard web application.

import topicwizard

topicwizard.visualize(texts, pipeline=topic_pipeline)
Screenshot of topics.

You can also you individual interactive plots to create individual visualizations you might be interested in.

Here is an example of how you can visualize words’ relations to each other in a topic model:

from topicwizard.figures import word_map

word_map(corpus=texts, pipeline=pipeline)

This will open a new browser tab in which you can investigate topic models visually.